package dao;

import java.util.List;

import pojo.Questions;
import util.PreHandle;

public class QuestionsDao {

	public static final QuestionsDao QueDao = new QuestionsDao();

	public List<Questions> findAllQuestions() {

		String sql = "select answerCount,title,detaidDesc,lastModified,id from questions order by lastModified desc";

		List<Questions> questions = PreHandle.query(sql, Questions.class);

		return questions.size() == 0 ? null : questions;

	}
	
	public Boolean saveQuestions(Questions questions) {
		
		int i = 0;
		
		String sql="insert into questions (answerCount,title,detaidDesc,lastModified) values(?,?,?,?)";
		
		try {
			
		 i=	PreHandle.excuteUpdate(sql, questions);
		 
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return i==1;
		
	}

}
